package com.kapcb.secure.configuration.core;

import com.kapcb.secure.configuration.enums.AlgorithmType;
import com.kapcb.secure.configuration.enums.EncodeType;
import com.kapcb.secure.configuration.filter.SecureUtils;

/**
 * <a>Title: Base64Encryptor </a>
 * <a>Author: kapcb <a>
 * <a>Description: Base64Encryptor <a>
 *
 * @author Kpacb
 * @version 1.0
 * @date 2024/5/5 9:47
 * @since 1.0
 */
public class Base64Encryptor extends AbstractSecurerProvider {

    public Base64Encryptor(EncryptContext encryptContext) {
        super(encryptContext);
    }

    /**
     * 获得当前算法
     */
    @Override
    public AlgorithmType algorithm() {
        return AlgorithmType.BASE64;
    }

    /**
     * 加密
     *
     * @param value      待加密字符串
     * @param encodeType 加密后的编码格式
     */
    @Override
    public String encrypt(String value, EncodeType encodeType) {
        return SecureUtils.encryptByBase64(value);
    }

    /**
     * 解密
     *
     * @param value 待加密字符串
     */
    @Override
    public String decrypt(String value) {
        return SecureUtils.decryptByBase64(value);
    }
}
